<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="avicit.platform6.commons.utils.ViewUtil"%>
<%@page import="avicit.platform6.core.locale.PlatformLocalesJSTL"%>
<%@page import="java.util.Locale"%>
<%@page import="avicit.platform6.api.session.SessionHelper"%>
<%@page import="avicit.platform6.api.sysshirolog.impl.AfterLoginSessionProcess"%>
<%
    Object lang=session.getAttribute(AfterLoginSessionProcess.SESSION_CURRENT_LANGUAGE_CODE);
    String languageCode="zh_CN";
    if(lang!=null){
        languageCode=lang.toString();
    }
    Locale locale =SessionHelper.getLocaleByUser(request);
%>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%--报表配置 --%>
    <title><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.button.reportConfiguration","i18n.lantop",locale)%></title>
    <base href="<%=ViewUtil.getRequestPath(request)%>">
    <jsp:include
            page="/avicit/platform6/component/common/EasyUIJsInclude.jsp"></jsp:include>
    <jsp:include page="/avicit/im/common/ImUIJSCSSInclude.jsp"></jsp:include>
    <script type="text/javascript" src="avicit/im/lantop/basic/reportmanager/js/PrintReportConfig.js"></script>

    <script type="text/javascript"
            src="avicit/im/lantop/basic/reportmanager/locale/language_<%=languageCode%>.js"></script>
</head>
<script type="text/javascript">
    var baseurl = "<%=ViewUtil.getRequestPath(request)%>";
    var dialogId = '${dialogId}'; 			// 对话框ID
    var templateId = "${templateId}";		// 模板ID
    var type = "${type}";					// 1 从配置按钮取消按钮到这里， 2 选择页面配置报表
    var resultDataSource = "${resultDataSource}";	// 配置表名集合
    var sysId = "${sysId}";				// 标识符
    var tableNameIds = '${tableNameIds}';	// 与之关联的表的集合,最多只有两个用, 分隔
    var colNamesDataGrid ;
    var columnsDataGrid ;
    var outputFields = [];
    var fieldsCount;
    var sql ;

    var nodesFieldIndex = {};

    $(function(){
        colNamesDataGrid = $("#colNamesDataGrid");
        columnsDataGrid = $("#columnsDataGrid");


        fields = '${outPutFields}';
        fieldCount = Number('${fieldsCount}');
        // 通过AJAX请求获取表中的字段
        $.ajax({
            url : 'platform/ReportFormConfigController/getTableListByTableIds',
            dataType : 'json',
            data : {
                sysId : sysId,
                tableIds : tableNameIds,
                templateId : templateId
            },
            success : function(result){
                // 获取数据成功后，加载到datagrid中
                $("#columnsDataGrid").datagrid('loadData', result.rows);
                $("#colNamesDataGrid").datagrid("loadData", result.setFields);
                getCurrColumnForCurrOutput();
            }

        });

    });


    function formatterField(value,row,index){
        var colName = row.COL_NAME;
        if(colName == undefined || colName == null || colName == "" ){
            return value;
        }
        return  row.TABLE_TITLE + "." + value;
    }


</script>
<body class="easyui-layout">

<div data-options="region:'north',split:false,border:false" style="height:100px;overflow-x: auto; overflow-y: hidden;">

    <div style="padding-left:10px;margin: 4px;height:35px;">
        <table align="center" class="form_commonTable">
            <tr>
                <%--报表应输出字段： --%>
                <th width="20%"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.printreportconfig.reportshouldoutputfields","i18n.lantop",locale)%></th>
                <td>
                    <input id="output" class="easyui-validatebox" value="${outPutFields} " readonly="true" />
                </td>
            </tr>
            <tr>
                <%--实际应输出字段： --%>
                <th width="20%"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.printreportconfig.reportinfactoutputfields","i18n.lantop",locale)%></th>
                <td>
                    <input id="currOutput" class="easyui-validatebox" data-options="required:true" readonly="true"/>
                </td>

            </tr>
        </table>
    </div>
</div>


<div data-options="region:'center',border:false" overflow-y: auto;">

<div id="cc" class="easyui-layout" fit="true">

    <div data-options="region:'east',iconCls:'icon-reload',noheader:true,split:false" style="width:400px;">
        <table id="colNamesDataGrid" class="easyui-datagrid"
               data-options="
							fit:true,
							animate: true,
							collapsible: false,
							fitColumns: true,
							autoRowHeight: false,
							singleSelect: true,
							striped:true,
							rownumbers: true,
							method: 'post',
							rowStyler: rowColor,
							remoteSort : false
						">
            <thead>
            <tr>
                <sec:accesscontrollist hasPermission="3" domainObject="excel_export_datagrid_id">														<%--表名--%>
                    <th data-options="field:'TABLE_NAME',  hidden:true ,  halign:'center', align:'center', sortable:false," width="200" title="表名"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.reportformconfig.tablename","i18n.lantop",locale)%></th>
                </sec:accesscontrollist>

                <sec:accesscontrollist hasPermission="3" domainObject="excel_export_datagrid_id">														<%--表名--%>
                    <th data-options="field:'TABLE_TITLE',  hidden:true ,  halign:'center', align:'center', sortable:false," width="200" title="表名"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.reportformconfig.tablename","i18n.lantop",locale)%></th>
                </sec:accesscontrollist>

                <sec:accesscontrollist hasPermission="3" domainObject="excel_export_datagrid_id">														<%--字段名称--%>
                    <th data-options="field:'COL_NAME',  hidden:true , halign:'center', align:'center', sortable:false," width="200" title="字段名称"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.reportformconfig.filedname","i18n.lantop",locale)%></th>
                </sec:accesscontrollist>

                <sec:accesscontrollist hasPermission="3" domainObject="excel_export_choose_datagrid_colName">											<%--字段名称--%>
                    <th data-options="field:'COL_LABEL', halign:'center', align:'center', sortable:false,formatter:formatterField"width="200" title="字段名称"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.reportformconfig.filedname","i18n.lantop",locale)%></th>
                </sec:accesscontrollist>
            </tr>
            </thead>
        </table>

    </div>

    <div id = "center" data-options="region:'center',title:'center title', noheader:true,split:false" style="padding:5px;background:#eee;">
        <table align="center">
            <tr>
                <td><sec:accesscontrollist hasPermission="3"
                                           domainObject="excel_export_button_oneAdd">
                    <%-- 选值右移 --%>
                    <input type="button" style="width: 80px; text-align: 'center';"
                           title="<%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.printreportconfig.valuerightmove","i18n.lantop",locale)%>" onclick="oneAdd();" value="【 >】"
                           href="javascript:void(0);"></input>
                </sec:accesscontrollist></td>
            </tr>
            <tr>
                <td><sec:accesscontrollist hasPermission="3"
                                           domainObject="excel_export_button_allAdd">
                    <%-- 全右移 --%>
                    <input type="button" style="width: 80px; text-align: 'center';"
                           title="<%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.printreportconfig.allvaluerightmove","i18n.lantop",locale)%>" onclick="allAdd();" value="【>>】"
                           href="javascript:void(0);"></input>
                </sec:accesscontrollist></td>
            </tr>
            <tr>
                <td><sec:accesscontrollist hasPermission="3"
                                           domainObject="excel_export_button_oneRemove">
                    <%-- 选值左移 --%>
                    <input type="button" style="width: 80px; text-align: 'center';"
                           title="<%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.printreportconfig.valueleftmove","i18n.lantop",locale)%>" onclick="oneRemove();" value="【 <】"
                           href="javascript:void(0);"></input>
                </sec:accesscontrollist></td>
            </tr>
            <tr>
                <td>
                    <sec:accesscontrollist hasPermission="3"
                                           domainObject="excel_export_button_allRemove">
                        <input type="button" style="width: 80px; text-align: 'center';"
                               onclick="allRemove();" value="【<<】" href="javascript:void(0);"></input>
                    </sec:accesscontrollist></td>
            </tr>

        </table>
    </div>

    <div data-options="region:'west',noheader:true,split:false" style="width:400px;">
        <table id="columnsDataGrid" class="easyui-datagrid"
               data-options="
								fit:true,
								animate: true,
								collapsible: false,
								fitColumns: true,
								autoRowHeight: false,
								singleSelect: true,
								striped:true,
								method: 'post',
								rownumbers: true,
								onDblClickRow: oneAdd,
								rowStyler: rowColor,
								remoteSort : true,
							">
            <thead>
            <tr>
                <sec:accesscontrollist hasPermission="3" domainObject="excel_export_datagrid_id">													<%--表名--%>
                    <th data-options="field:'TABLE_NAME',  hidden:true ,  halign:'center', align:'center', sortable:false," width="200" title="表名"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.reportformconfig.tablename","i18n.lantop",locale)%></th>
                </sec:accesscontrollist>

                <sec:accesscontrollist hasPermission="3" domainObject="excel_export_datagrid_id">													<%--字段名称--%>
                    <th data-options="field:'TABLE_TITLE',  hidden:true , halign:'center', align:'center', sortable:false," width="200" title="字段名称"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.reportformconfig.filedname","i18n.lantop",locale)%></th>
                </sec:accesscontrollist>

                <sec:accesscontrollist hasPermission="3" domainObject="excel_export_datagrid_id">													<%--字段名称--%>
                    <th data-options="field:'COL_NAME',  hidden:true , halign:'center', align:'center', sortable:false," width="200" title="字段名称"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.reportformconfig.filedname","i18n.lantop",locale)%></th>
                </sec:accesscontrollist>



                <sec:accesscontrollist hasPermission="3" domainObject="excel_export_column_datagrid_colName">													<%--字段名称--%>
                    <th data-options="title:'', field:'COL_LABEL', halign:'center', align:'center', sortable:false,formatter:formatterField" width="200" title="字段名称"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.reportformconfig.filedname","i18n.lantop",locale)%></th>
                </sec:accesscontrollist>
            </tr>
            </thead>
        </table>

    </div>

</div>


</div>


<div data-options="region:'south',split:false,border:true,align:'center',fit:false" style="overflow-y: hidden;">
    <div id="toolbar"class="datagrid-toolbar" style="height:40px;">
        <table align="center">
            <tr>
                <td>
                    <sec:accesscontrollist  hasPermission="3" domainObject="excel_export_button_exportData" >
                        <%--保存--%>
                        <a id="saveBtn" title="<%=PlatformLocalesJSTL.getBundleValue("lantop.save","i18n.lantop",locale)%>" data-options="disabled:false" class="easyui-linkbutton"  iconCls="icon-im-export" plain="true" onclick="save();" href="javascript:void(0);"><%=PlatformLocalesJSTL.getBundleValue("lantop.save","i18n.lantop",locale)%></a>
                    </sec:accesscontrollist>
                </td>
                <td>
                    <sec:accesscontrollist  hasPermission="3" domainObject="excel_export_button_cancle" >
                        <%--关闭--%>
                        <a id="cancleBtn" title="<%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.usercustomdatasource.close","i18n.lantop",locale)%>"  class="easyui-linkbutton"  iconCls="icon-im-close-all" plain="true" onclick="cancle();" href="javascript:void(0);"><%=PlatformLocalesJSTL.getBundleValue("lantop.basicdatamanager.reportmanager.usercustomdatasource.close","i18n.lantop",locale)%></a>
                    </sec:accesscontrollist>
                </td>
            </tr>
        </table>
    </div>
</div>
</body>
</html>